#ifndef SENSORSYSTEM_H
#define SENSORSYSTEM_H

#include "Common.h"
#include "myhash.h"
#include "AVLTree.h"
#include "sensorlatitudegenerator.h"
#include "sensortemperaturegenerator.h"

typedef AVLTree<LatitudeKeyPair, SensorPtr, SensorTemperatureGenerator, SensorLatitudeGenerator>
		LatitudeSensorTree;

class SensorSystem
{
public:
	SensorSystem();

	void AddSensor(int id, Rational latitude, Rational temperature);

	void RemoveSensor(int id);

	void ChangeSensorTemp(int id, Rational temp);

	Rational GetSensorTemp(int id) const;

	Rational AverageTempInRange(Rational fromLatitude, Rational toLatitude) const;

	Rational MaxTempInRange(Rational fromLatitude, Rational toLatitude) const;

private:
	LatitudeKeyPair GetTreeKey(int id) const;

	myHash<SensorPtr> _sensorHash;
	LatitudeSensorTree _sensorTree;
};

#endif // SENSORSYSTEM_H
